package au.com.helloweb.androidgamepractice.planegame2;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;

public class GameBg {
	//define two bitmap
	private Bitmap bitmapBackground1;
	private Bitmap bitmapBackground2;
	private int bg1x,bg1y,bg2x,bg2y;
	private int speed = 3;
	
	public GameBg(Bitmap bmpBackground){
		this.bitmapBackground1 = bmpBackground;
		this.bitmapBackground2 = bmpBackground;
		
		bg1y = -Math.abs(bitmapBackground1.getHeight()-MySurfaceView.screenH);
		bg2y = bg1y-bitmapBackground2.getHeight()+111;
	}
	
	public void draw(Canvas canvas,Paint paint){
		canvas.drawBitmap(bitmapBackground1, bg1x,bg1y, paint);
		canvas.drawBitmap(bitmapBackground2, bg2x, bg2y, paint);
	}
	
	public void logic(){
		bg1y += speed;
		bg2y += speed;
		if(bg1y > MySurfaceView.screenH){
			bg1y = bg2y-bitmapBackground1.getHeight()+111;
		}
		if(bg2y>MySurfaceView.screenH){
			bg2y = bg1y-bitmapBackground2.getHeight()+111;
		}
	}
}
